//
//  FontInfoView.m
//  SystemFontTest
//
//  Created by Chris Yang on 16/9/18.
//  Copyright © 2016年 Chris Yang. All rights reserved.
//

#import "UIFont+MZCategory.h"

#import "FontInfoView.h"

@implementation FontInfoView

- (id)init {
    
    self = [super init];
    
    if (self) {
        [self configSelf];
        [self allocSubviews];
        [self configSubviews];
        [self positionSubviews];
    }
    
    return self;
}

- (void)configSelf {
    
}

- (void)allocSubviews {
    _testLabel = [[UILabel alloc] init];
    _fontNameLabel = [[UILabel alloc] init];
}

- (void)configSubviews {
 
    /* Test Lable */
    [_testLabel setText:@"测试ABCabc"];
    [_testLabel setTextColor:[UIColor redColor]];
    [_testLabel setTextAlignment:NSTextAlignmentLeft];
    [_testLabel setAdjustsFontSizeToFitWidth:YES];
    
    /* Font Name Laebl */
    [_fontNameLabel setText:@"字体名称："];
    [_fontNameLabel setTextColor:[UIColor blueColor]];
    [_fontNameLabel setFont:mzAdaptiveFont(16, 2)];
    [_fontNameLabel setTextAlignment:NSTextAlignmentLeft];
    [_fontNameLabel setAdjustsFontSizeToFitWidth:YES];

    [self addSubview:_testLabel];
    [self addSubview:_fontNameLabel];
}

- (void)positionSubviews {
    CGRect tmpRect = CGRectZero;
    
    /* Test Label */
    tmpRect = CGRectMake(20, 0, 130, self.frame.size.height);
    [_testLabel setFrame:tmpRect];
    
    /* Font Name Label */
    tmpRect = CGRectMake(150, 0, 230, self.frame.size.height);
    [_fontNameLabel setFrame:tmpRect];
}

- (void)layoutSubviews {
    [self positionSubviews];
}

#pragma mark - Target-Action Pair

- (void)buttonClicked:(UIButton *)button {
    
}

#pragma mark - MISC

#pragma mark - User Interface

+ (FontInfoView *)fontViewWithFontName:(NSString *)fontName {
    
    FontInfoView *fontView = [[FontInfoView alloc] init];
    
    [fontView.testLabel setFont:[UIFont mzAdaptiveFontWithFontName:fontName baseSize:14 reduce:3]];
    [fontView.fontNameLabel setFont:mzAdaptiveFont(14, 3)];
    [fontView.fontNameLabel setText:[NSString stringWithFormat:@"%@", fontName]];
    
    return fontView;
}

@end
